#include<stdio.h>
#define M 4
#define N 100

int main()
{
    int a[M]={10,8,8,6},b[N]={1,2,3,4,5,6,7,8,9,10};
    int lena=M,lenb=10,flag=0;
    for(int i=0;i<lena;i++){
        if(a[i]<=b[0]){
            for(int k=lenb-1;k>=0;k--){
                b[k+1]=b[k];
            }
            b[0]=a[i];
            lenb++;
            continue;
        }
        if(a[i]>=b[lenb-1]){
            b[lenb]=a[i];
            lenb++;
            continue;
        }
        for(int j=0;j<lenb;j++){
            if(b[j]<=a[i]&&b[j+1]>=a[i]){
                for(int k=lenb-1;k>=j;k--){
                    b[k+1]=b[k];
                }
                lenb++;
                b[j+1]=a[i];
                break;
            }
        }
    }
    for(int i=0;i<lenb-1;i++){
        printf("%d ",b[i]);
    }
    printf("%d",b[lenb-1]);
}